// component/coupon-list.js
const config = require('../../config.js');
const request = require('../../utils/request.js')
const utils = require('../../utils/util.js');
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    searchParams:Object,
    isShow:Boolean,
  },
    attached:function(){
        let that = this;
        this.getCouponList(this.data.searchParams)
        setTimeout(function(){
            that.setData({
                iscShow:true
            })
        })
    },
  /**
   * 组件的初始数据
   */
  data: {
      couponList:null
  },
  /**
   * 组件的方法列表
   */
  methods: {
      _hideDialog(e){
          console.log(e)
          let dataset = e.currentTarget.dataset;
          if (dataset.type == "1"){
              this.triggerEvent('closePop', {
                  type: 1
              });
          }else{
              this.triggerEvent('closePop', {
                  type: dataset.type,
                  item: dataset.item
              });
          }
          
      },
      //获取优惠券信息
      getCouponList(options) {
          let that = this
          wx.showLoading({
              title: '加载中...',
          })
          request.ajaxRequest({
              url: '/wap/api/?task=ItemCouponOrdercoupon',
              params: {
                  order_id: options.order_id
              },
              successCb: function (data) {
                  wx.hideLoading();
                  console.log('优惠券信息')
                  console.log(data)
                  that.setData({
                      couponList: data.coupon_list
                  })

              },
              errorCb: function () {
                  wx.hideLoading();
              }
          })
      }
  },
  
})
